/*
 * @Author: zhang zhijiang 2824735304@qq.com
 * @Date: 2025-04-16 15:42:15
 * @LastEditors: zhang zhijiang 2824735304@qq.com
 * @LastEditTime: 2025-04-17 17:34:55
 * @FilePath: /linux/test_4_16/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"udpserver.hpp"
void usage(string proc)
{
    cout<< "right usage :"<<proc<<"[1024+]"<<endl;
}
string func(const string & s)
{
    string info = "get a message";
    return info+=s;
}
bool checksafe(const string& cmd)
{
    vector<string> check_word = {"mv"
    ,"rm"
    ,"kill"
    ,"cd"};
    for(auto& word:check_word)
    {
        if(word==cmd)
        return false;
    }
    return true;


}
string execute(const string & cmd)
{
    if(checksafe(cmd));
    {
        return "bad man";
    }
    FILE* file = popen(cmd.c_str(),"r");
    string result;
    while(1)
    {
        char buffer[2048];
       char* ok= fgets(buffer,sizeof(buffer),file);
        if(ok==nullptr)
        break;
        result+=buffer;
    }
    fclose(file);
    return result;
}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        usage(argv[0]);
        exit(1);
    }
    uint16_t port = stoi(argv[1]);//字符串转整数
   unique_ptr<server>svr(new server(port));
    svr->init();
    svr->run();
   // svr->~server();
    return 0;
}